﻿-- =============================================
-- Author:		GSJ
-- Create date: 2012-6-30
-- Description:	往来收入列表
-- =============================================
CREATE PROCEDURE [dbo].[proc_L_Dealings_GetList_BYIOCompanyId]
	(
		@O_CompanyId INT,		
		
		@I_CompanyId int
		
	)
AS
BEGIN
	   ;WITH  list AS(     SELECT ROW_NUMBER() OVER (ORDER BY createdate  ) AS Row
           ,id,[O_CompanyId]
           ,[O_CompanyName]
           ,[O_PaymentTypeId]
           ,[O_PaymentTypeName]
           ,[O_BankId]
           ,[O_BankName]
           ,[I_CompanyId]
           ,[I_CompanyName]
           ,[I_PaymentTypeId]
           ,[I_PaymentTypeName]
           ,[I_BankId]
           ,[I_BankName]
           ,[je]
           ,[Agent]
           ,[AgentName]
           ,[PZPerson]
           ,[PZPersonName]
           ,[SHPerson]
           ,[SHPersonName]
           ,[UserId]
           ,[UserName]
           ,[Memo]
           ,CreateDate
           
	FROM  [L_Dealings] WHERE (O_CompanyId=@O_CompanyId and I_CompanyId=@I_CompanyId) 
		
	   )
	   SELECT * FROM list,(SELECT COUNT(1) AS DataCount,SUM(je) AS DataSum FROM list) AS l1 
END
